﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfMvvmDemo
{
    public class CodeHelper
    {
        public CodeHelper()
        {
            
        }

        /// <summary>
        /// 以资源形式获取源码
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static string GetCode(string filePath)
        {
            var uri = new Uri(filePath, UriKind.Relative);
            var resourceStream = Application.GetResourceStream(uri);
            if (resourceStream != null)
            {
                using var reader = new StreamReader(resourceStream.Stream);
                var code = reader.ReadToEnd();
                return code;
            }

            return "";
        }
    }
}
